package homework_2;

import java.util.Random;

public class Student {
	static private int[] totalEachScore = { 0, 0, 0, 0, 0};
	static private Random rand = new Random();
	private int[] score = { 0, 0, 0, 0, 0};
	private String id;
	private String name;
	private float averageScore = 0;
	private int totalScore = 0;
	
	public Student(String n, String i) {
		name = n;
		id = i;
		for (int m = 0 ; m < score.length; m++) {
			score[m] = nextScore();
			totalScore += score[m];
			totalEachScore[m] += score[m];
		}
		averageScore = totalScore / (float)5;
	}
	public int getTotalScore() {
		return totalScore;
	}
	public String scoreTableLine() {
		String line = name + "," + id;
		for (int i : score) {
			line += "," + i;
		}
		return line + "\n";
	}
	public String sortedScoreLine() {
		String line = name + "," + id;
		for (int i : score) {
			line += "," + i;
		}
		line += "," + averageScore ;
		line += "," + totalScore;
		return line + "\n";
	}
	private int nextScore() {
		int num = (int)(Math.sqrt(100)*rand.nextGaussian()) + 75;
		if(num > 100) {
			num = 100;
		} else if(num < 50) {
			num = 50;
		}
		return num;
	}
	public static int[] getTotalEachScore() {
		return totalEachScore;
	}
}
